<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
// 返回json结构

function show($stauts, $msg, $data = [], $httpCode = 200){
	$data = [
		'status'  => $stauts,
		'msg'     => $msg,
		'data' 	  => $data,
	];
	return json($data,$httpCode);
}

// 风格时间
function dayTime($time = array()) {
	$stimestamp = strtotime($time['start_time']);
	$etimestamp = strtotime($time['end_time']);
	
	$days = ($etimestamp - $stimestamp) / 86400 + 1;
	$date = array();

	for ($i=0; $i < $days; $i++) { 
		$date[] = date("Y-m-d", $stimestamp + (86400*$i));
	}
	return $date;
}

function getRandChar($length)
{
    $str = null;
    $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    $max = strlen($strPol) - 1;

    for ($i = 0;
         $i < $length;
         $i++) {
        $str .= $strPol[rand(0, $max)];
    }

    return $str;
}